﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;

namespace AgileShare.Framework.SiteProvisioning.Definitions
{
	public class ContentTypeDefinition
	{
		/// <summary>
		/// Initializes a new instance of the <see cref="ContentTypeDefinition" /> class.
		/// </summary>
		public ContentTypeDefinition()
		{
			this.FieldLinkDefinitions = new List<FieldLinkDefinition>();
		}

		/// <summary>
		/// Initializes a new instance of the <see cref="ContentTypeDefinition"/> class.
		/// </summary>
		/// <param name="contentTypeId">The content type id.</param>
		/// <param name="name">The name.</param>
		/// <param name="description">The description.</param>
		/// <param name="group">The group.</param>
		/// <param name="fieldLinks">The field links.</param>
		public ContentTypeDefinition(SPContentTypeId contentTypeId, string name, string description, string group, params FieldLinkDefinition[] fieldLinks)
		{
			this.Id = contentTypeId;
			this.Name = name;
			this.Description = description;
			this.Group = group;
			this.FieldLinkDefinitions = fieldLinks.ToList();
		}

		/// <summary>
		/// Initializes a new instance of the <see cref="ContentTypeDefinition"/> class.
		/// </summary>
		/// <param name="contentTypeId">The content type id.</param>
		/// <param name="name">The name.</param>
		/// <param name="description">The description.</param>
		/// <param name="group">The group.</param>
		/// <param name="hidden">The hidden.</param>
		/// <param name="readOnly">The read only.</param>
		/// <param name="isSealed">The is sealed.</param>
		/// <param name="fieldLinks">The field links.</param>
		public ContentTypeDefinition(SPContentTypeId contentTypeId, string name, string description, string group, bool? hidden, bool? readOnly, bool? isSealed, params FieldLinkDefinition[] fieldLinks)
			: this(contentTypeId, name, description, group, fieldLinks)
		{
			this.Hidden = hidden;
			this.ReadOnly = readOnly;
			this.Sealed = isSealed;
		}

		/// <summary>
		/// Initializes a new instance of the <see cref="ContentTypeDefinition" /> class.
		/// </summary>
		/// <param name="contentTypeId">The content type id.</param>
		/// <param name="name">The name.</param>
		/// <param name="description">The description.</param>
		/// <param name="group">The group.</param>
		/// <param name="fieldLinks">The field links.</param>
		public ContentTypeDefinition(string contentTypeId, string name, string description, string group, params FieldLinkDefinition[] fieldLinks)
			: this(new SPContentTypeId(contentTypeId), name, description, group, fieldLinks) { }

		/// <summary>
		/// Initializes a new instance of the <see cref="ContentTypeDefinition" /> class.
		/// </summary>
		/// <param name="contentTypeId">The content type id.</param>
		/// <param name="name">The name.</param>
		/// <param name="description">The description.</param>
		/// <param name="group">The group.</param>
		/// <param name="hidden">The hidden.</param>
		/// <param name="readOnly">The read only.</param>
		/// <param name="isSealed">The is sealed.</param>
		/// <param name="fieldLinks">The field links.</param>
		public ContentTypeDefinition(string contentTypeId, string name, string description, string group, bool? hidden, bool? readOnly, bool? isSealed, params FieldLinkDefinition[] fieldLinks)
			: this(new SPContentTypeId(contentTypeId), name, description, group, fieldLinks) { }


		/// <summary>
		/// Gets or sets the content type id.
		/// </summary>
		/// <value>
		/// The content type id.
		/// </value>
		public SPContentTypeId Id { get; set; }

		/// <summary>
		/// Gets or sets the description.
		/// </summary>
		/// <value>
		/// The description.
		/// </value>
		public string Description { get; set; }

		/// <summary>
		/// Gets or sets the group.
		/// </summary>
		/// <value>
		/// The group.
		/// </value>
		public string Group { get; set; }

		/// <summary>
		/// Gets or sets a value indicating whether this <see cref="ContentTypeDefinition"/> is hidden.
		/// </summary>
		/// <value>
		///   <c>true</c> if hidden; otherwise, <c>false</c>.
		/// </value>
		public bool? Hidden { get; set; }

		/// <summary>
		/// Gets or sets the name.
		/// </summary>
		/// <value>
		/// The name.
		/// </value>
		public string Name { get; set; }

		/// <summary>
		/// Gets or sets a value indicating whether [read only].
		/// </summary>
		/// <value>
		///   <c>true</c> if [read only]; otherwise, <c>false</c>.
		/// </value>
		public bool? ReadOnly { get; set; }

		/// <summary>
		/// Gets or sets a value indicating whether this <see cref="ContentTypeDefinition"/> is sealed.
		/// </summary>
		/// <value>
		///   <c>true</c> if sealed; otherwise, <c>false</c>.
		/// </value>
		public bool? Sealed { get; set; }

		/// <summary>
		/// Gets or sets the field definition collection.
		/// </summary>
		/// <value>
		/// The field definition collection.
		/// </value>
		public List<FieldLinkDefinition> FieldLinkDefinitions { get; set; }

		// More properties
		//public string DisplayFormTemplateName { get; set; }
		//public string DisplayFormUrl { get; set; }
		//public string DocumentTemplate { get; set; }
		//public string EditFormTemplateName { get; set; }
		//public string EditFormUrl { get; set; }
		//public string MobileDisplayFormUrl { get; set; }
		//public string MobileEditFormUrl { get; set; }
		//public string MobileNewFormUrl { get; set; }
		//public string NewDocumentControl { get; set; }
		//public string NewFormTemplateName { get; set; }
		//public string NewFormUrl { get; set; }
		//public bool? RequireClientRenderingOnNew { get; set; }
	}
}
